<template>
	<u-popup v-model="show" mode="center" border-radius="28" bgColor="rgba(255,255,255,0)">
		<view class="zdy-pop">
			<view class="qrCode-pop">
				<image class="bg" src="/static/user/sharebg.png" mode="aspectFill"></image>
				<view class="info">
					<view class="top">
						<view class="avatar">
							<image :src="userinfo.avatar" mode="aspectFill"></image>
						</view>
						<view class="userinfo">
							<view class="name">{{ userinfo.nickname }}</view>
							<view class="phone">{{ userinfo.id }}</view>
						</view>
					</view>
					<view class="qrcode">
						<image :src="img" mode=""></image>
					</view>
					<button class="save" @click="handSave">保存图片并分享好友</button>
				</view>
				<!-- <view class="avatar">
					<image :src="userinfo.avatar" mode="aspectFill"></image>
				</view>
				<view class="name">{{ userinfo.nickname }}</view>
				<view class="phone">{{ userinfo.id }}</view>
				<view class="qrcode">
					<image :src="img" mode=""></image>
				</view>
				<button class="save" @click="handSave">保存图片并分享好友</button> -->
			</view>
		</view>
	</u-popup>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		baseURL
	} from '@/config/index.js';
	import {
		saveImg
	} from '@/utils/utils.js'
	export default {
		data() {
			return {
				show: false,
				img: '',
				type: '',
			}
		},
		computed: {
			...mapGetters('app', {
				userinfo: 'userinfo'
			})
		},
		methods: {
			handSave() {
				saveImg(this.img)
			},
			showEdit() {
				// // 判断平台
				// #ifdef MP-WEIXIN
				this.type = 'wx'
				// #endif
				// #ifdef MP-TOUTIAO
				this.type = 'dy'
				// #endif
				let token = uni.getStorageSync('token')
				this.img = `${baseURL}/index/user/shareQr?user_id=${this.userinfo.id}&type=${this.type}&token=${token}`
				this.show = true
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zdy-pop {
		padding-top: 80rpx;
	}

	.qrCode-pop {
		width: 633rpx;
		position: relative;

		.bg {
			width: 633rpx;
			height: 864.61rpx;
		}

		.info {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;

			.top {
				display: flex;
				align-items: center;
				padding-top: 60rpx;
				padding-left: 24rpx;

				.avatar {
					image {
						width: 106rpx;
						height: 106rpx;
						border-radius: 50%;
					}
				}

				.userinfo {
					flex: 1;
					margin-left: 24rpx;

					.name {
						font-size: 32rpx;
						font-family: PingFang SC-Bold, PingFang SC;
						font-weight: bold;
						color: #FFFFFF;
					}

					.phone {
						margin-top: 8rpx;
						font-size: 26rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #FFFFFF;
					}
				}
			}

			.qrcode {
				margin-top: 90rpx;
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 324rpx;
					height: 338rpx;
				}
			}
		}

		.save {
			margin-top: 80rpx;
			width: 474rpx;
			height: 94rpx;
			background: linear-gradient(180deg, #2CE167 0%, #04B87C 100%);
			border-radius: 50rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: center;

			&::after {
				border: none;
			}
		}
	}
</style>